package com.github.tetrisgame.manager;

import com.github.tetrisgame.model.Block;

public class BlockManager {
    public static final BlockManager defaultManager = new BlockManager();
    //保存预览方块对象
    private Block previewBlock ;
    //保存正在显示的方块对象
    private Block currentBlock;

    //私有化构造方法
    private BlockManager(){}

    public void resetPosition(int row, int colum){
        currentBlock.row = 0;
        currentBlock.column = colum/2-1;

        previewBlock.row = 0;
        previewBlock.column = colum/2-1;
    }

    //获取预览方块
    public Block getPreviewBlock(int row, int column){
        if (currentBlock == null){
            //第一次获取方块
            //给currentBlock一个方块
            currentBlock = new Block(row,column);
        }else{
            //上一个预览方块就是现在正在操作的方块
            currentBlock = previewBlock;
        }
        //创建一个新的Block对象
        previewBlock = new Block(row,column);
        return previewBlock;
    }

    //获取当前正在操作的方块
    public Block getCurrentBlock(){
        return currentBlock;
    }
}
